#include <iostream>
using namespace std;
#include<vector>
namespace bit
{
	template<class T>
	class myless
	{
	public:
		bool operator()(const T& x, const T& y)
		{
			return x < y;
		}
	};

	template<class T>
	class greater
	{
	public:
		bool operator()(const T& x, const T& y)
		{
			return x > y;
		}
	};
	template<class T, class Container = vector<T>, class Compare = myless<T>>
	class priority_queue{
    public:
		void adjustup(int child)
		{
			Compare fun;
			int parent = (child - 1) / 2;
			while (child > 0)
			{
				if (fun(_con[parent]), _con[child])
				{
					swap(_con[child], _con[parent]);
					child = parent;
					parent = (child - 1) / 2;
				}
				else {
					break;
				}
			}
		}
		void adjustdown(int parent)
		{
			compare fun;
			int child = parent * 2 + 1;
			while (child < _con.size())
			{
				if (child + 1 < _con.size() && fun(_con[child], _con[child + 1]))
				{
					child++;
				}
				if (fun(_con[parent], _con[child]))
				{
					swap(_con[parent], _con[child]);
					parent = child;
					child = parent * 2 + 1;
				}
				else
					break;
			}
		}
		template<class IuputIterator>
		priority_queue(IuputIterator first, IuputIterator last)
		{
			while (first != last)
			{
				_con.pushback(*first);
				first++;
			}
			for (int i = (_con.size() - 1 - 1) / 2; i >= 0; i--)
			{
				adjustdown(i);
			}
		}
		void push(const T& x)
		{
			_con.pushback(x);
			adjustup(_const.size()-1);
		}
		void pop()
		{
			swap(_con[0], _con[_con.size() - 1]);
			_con.pop_back();
			adjustdown(0);
		}
		const T& top()
		{
			return _con[0];
		}
		size_t size()
		{
			return _con.size();
		}
		bool empty()
		{
			return _con.empty();
		}
	private:
		Container _con;
	};
}